﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ECCIT.Report.Excel
{
    public class HtmlTemplateRow : HtmlTemplateElement
    {
        private List<HtmlTemplateCell> _cells;

        public List<HtmlTemplateCell> Cells
        {
            get { return _cells; }
            set { _cells = value; }
        }

        public override string InnerText
        {
            get
            {
                StringBuilder builder = new StringBuilder();
                foreach (HtmlTemplateCell cell in _cells)
                {
                    builder.Append(cell.ToString()).Append(Environment.NewLine);
                }

                return builder.ToString();
            }
            set
            {
                base.InnerText = value;
            }
        }

        public HtmlTemplateRow(int index, string start, string end)
            : base(index, start, end)
        {
            _cells = new List<HtmlTemplateCell>();
        }

        public HtmlTemplateRow Clone()
        {
            HtmlTemplateRow row = new HtmlTemplateRow(this.Index, this.Start, this.End);
            row.Cells = new List<HtmlTemplateCell>(_cells.Count);
            foreach (HtmlTemplateCell cell in _cells)
                row.Cells.Add(cell.Clone());

            return row;
        }
    }
}
